package ro.licenta.tama;

import ro.licenta.utilities.utils.StaticUtils;

public class Tama {

	// tAge = 1 (child)
	// tAge = 2 (Mature)
	// tAge = 3 (Old)
	// tAge = 4 (Dead)
	private int tHp, tFull, tEne, tFun, tAge, tToyPosition = StaticUtils.error,
			tBedPosition = StaticUtils.error,
			tStuffPosition = StaticUtils.error,
			tLampPosition = StaticUtils.error,
			tFoodPosition = StaticUtils.error, tResultRoom = StaticUtils.error,
			tLifespan, tUpdateService;
	private boolean tSleeping, tSound = true, tThesys = false, tFed = false, tPlay;

	private static Tama instance = null;

	private Tama() {
	}

	public static Tama getInstance() {
		if (instance == null)
			instance = new Tama();
		return instance;
	}

	public int getAge() {
		return tAge;
	}

	public int getHp() {
		return tHp;
	}

	public int getEne() {
		return tEne;
	}

	public int getFull() {
		return tFull;
	}

	public int getFun() {
		return tFun;
	}

	public int getToyPosition() {
		return tToyPosition;
	}

	public int getLifespan() {
		return tLifespan;
	}

	public int getLifeCycle() {
		int tLifeCycle = -1;
		switch (tAge) {
		case StaticUtils.ageChild: {
			tLifeCycle = getLifespan() / 4;
			break;
		}
		case StaticUtils.ageMature: {
			tLifeCycle = getLifespan() / 2;
			break;
		}
		case StaticUtils.ageOld: {
			tLifeCycle = getLifespan() / 4;
			break;
		}
		}
		return tLifeCycle;
	}

	public void setAge(int val) {
		this.tAge = val;
	}

	public void setHp(int val) {
		if (val <= 100)
			this.tHp = val;
		else
			this.tHp = 0;
	}

	public void setEne(int val) {
		this.tEne = val;
	}

	public void setFull(int val) {
		this.tFull = val;
	}

	public void setFun(int val) {
		this.tFun = val;
	}

	public void setToyPosition(int val) {
		this.tToyPosition = val;
	}

	public void setLifeSpan(int val) {
		this.tLifespan = val;
	}

	public void setSleeping(boolean val) {
		this.tSleeping = val;
	}

	public boolean isDead() {
		if ((this.tHp == 0) || (this.tAge == 4))
			return true;
		else
			return false;
	}

	public boolean isSleeping() {
		return tSleeping;
	}

	public synchronized void modifyHp(int val) {
		if (val >= 0)
			this.tHp += val;
		else
			this.tHp += val;
		if (this.tHp > 100)
			this.tHp = 100;
		if (this.tHp <= 0)
			this.tHp = 0;
	}

	public synchronized void modifyHp() {
		if ((int) Math.floor((getEne() + getFull() + getFun()) / 3) <= 100) {
			this.tHp = (int) Math.floor((getEne() + getFull() + getFun()) / 3);
		} else
			this.tHp = 0;
	}

	public synchronized void modifyFull(int val) {

		this.tFull += val;
		if (this.tFull > 100)
			this.tFull = 100;
		if (this.tFull <= 0)
			this.tFull = 0;
	}

	public synchronized void modifyEne(int val) {

		this.tEne += val;
		if (this.tEne > 100)
			this.tEne = 100;
		if (this.tEne <= 0)
			this.tEne = 0;
	}

	public synchronized void modifyFun(int val) {

		this.tFun += val;
		if (this.tFun > 100)
			this.tFun = 100;
		if (tFun <= 0)
			this.tFun = 0;
	}

	public int getBedPosition() {
		return tBedPosition;
	}

	public void setBedPosition(int val) {
		this.tBedPosition = val;
	}

	public int getStuffPosition() {
		return tStuffPosition;
	}

	public void setStuffPosition(int val) {
		this.tStuffPosition = val;
	}

	public int getLampPosition() {
		return tLampPosition;
	}

	public void setLampPosition(int val) {
		this.tLampPosition = val;
	}

	public int getFoodPosition() {
		return tFoodPosition;
	}

	public void setFoodPosition(int val) {
		this.tFoodPosition = val;
	}

	public int getUpdateService() {
		return tUpdateService;
	}

	public void setUpdateService(int tUpdateService) {
		this.tUpdateService = tUpdateService;
	}

	public boolean isSound() {
		return tSound;
	}

	public void setSound(boolean val) {
		this.tSound = val;
	}

	public int getResultRoom() {
		return tResultRoom;
	}

	public void setResultRoom(int val) {
		this.tResultRoom = val;
	}
	
	public boolean isThesys() {
		return tThesys;
	}

	public void setThesys(boolean tThesys) {
		this.tThesys = tThesys;
	}

	public boolean isFed() {
		return tFed;
	}

	public void setFed(boolean val) {
		this.tFed = val;
	}

	public boolean isPlay() {
		return tPlay;
	}

	public void setPlay(boolean val) {
		this.tPlay = val;
	}


}
